home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4650 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.4 KB

  1. Path: news.lpr.carel.fi!usenet
  2. From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Newbie question on syntax of pointer to const
  5. Date: Wed, 31 Jan 1996 16:50:06 +0200
  6. Organization: Carelcomp Forest
  7. Message-ID: <310F819E.765B@cmt.lpr.mail.carel.fi>
  8. References: <4ej9eg$lq6@agate.berkeley.edu> <4ek468$jr1@clarknet.clark.net> <4ell6p$3f2q@yuma.ACNS.ColoState.EDU>
  9. NNTP-Posting-Host: renoir.cclahti.carel.fi
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (WinNT; I)
  14.  
  15. Dave Steffen wrote:
  16. >         What I'm curious about is the syntax of that second
  17. > line. Looking at Meyers' book, it looks like the const should come
  18. > after the *. In other words, are these the same:
  19. > double const * pc;
  20. > double * const pc;
  21. >         The second syntax I've seen and used; the first I'm not sure
  22. > of (and am too lazy to check the DWP right now ;-)
  23.  
  24. 'double const *pc' defines a pointer to a constant double (eg. you cannot change 
  25. the value pc is pointing to, but you can change the pc itself), 'double * const 
  26. pc' defines a constant pointer to a double (cannot change the pc's value, but can 
  27. change the value it's pointing to). The following, BTW, are identical (except for 
  28. typographics...):
  29.  
  30.     double const * pc;
  31.     const double * pc;
  32.  
  33. Later,
  34.  AriL
  35.  
  36.  
  37. -- 
  38. All my opinions are mine and mine alone.
  39.